home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u262.dms / in.adf / LISTINGS.RUN / convertfd / convertfd.s next >
Encoding:
Text File  |  1992-04-11  |  15.2 KB  |  613 lines

  1.  
  2. *-----------------------------------------------------------------------*
  3. *                                    *
  4. *        Commodore FD to _LVO file converter            *
  5. *                                    *
  6. *        By Toby W.Simpson                    *
  7. *        Copyright 1991 Toby W.Simpson, All rights reserved.    *
  8. *                                    *
  9. *-----------------------------------------------------------------------*
  10. ;        
  11.         section    ConvertFD,code
  12. ;
  13. ; ---- IO Buffer sizes ....
  14. RC_BUFFSIZE:    equ    100            ; 100 bytes file buffer
  15. ;
  16.         bra    BEGIN
  17. ;
  18. ; ---- Embedded (C)'s ....
  19. VERSION:    macro
  20.         dc.b    "1.14"
  21.         endm
  22. Title:        dc.b    "Amiga FD to _Lib.i converter",0
  23. CopyRight:    dc.b    "Copyright 1991 Toby W.Simpson, All rights reserved",0
  24. Author:        dc.b    "Toby W.Simpson",0
  25. Date:        dc.b    "January 1991",0
  26.         VERSION
  27.         dc.b    0
  28. ;
  29. ; ---- Includes ....
  30.         incdir    "inc:"
  31. ;
  32. ; ---- Since at this point you probably don't have the _lib.i files,
  33. ;      you need the funcdef.i in order to make the exec_lib.i file
  34. ;      from commodore actually work. If you DO have old _lib.i files
  35. ;      (From devpac) - include them and eliminate the funcdef.i line ....
  36.         include    "exec/funcdef.i"
  37.         include    "exec/exec_lib.i"
  38.         include    "dos/dos_lib.i"
  39.         even
  40. ;
  41. ; ---- Startup code ....
  42. ;      See after this for the startup.i code
  43. ;
  44.         include    "startup.i"
  45.         even
  46. ;
  47. ; -----------------------------------------------------------------------
  48. ;
  49. ;    Program loop.
  50. ;
  51. InFile:        dcb.b    40,0
  52. OutFile:    dcb.b    40,0
  53. ;
  54. ; ---- It adds this to the output file ....
  55. OutTerm:    dc.b    "_lib.i",0
  56. ;
  57. DOS:        macro    
  58.         move.l    ST_DosBase,a6
  59.         jsr    _LVO\1(a6)
  60.         endm
  61.  
  62. START:        lea    FD_Startup(pc),a0
  63.         jsr    PrintMessage
  64.         tst.l    ST_Message
  65.         bne    ST_MustCLI
  66. ;
  67. ; ---- Pull out filenames ....
  68. ; =====================================================================
  69. ;    THIS CHUNK OF CODE IS GARBAGE. 
  70. ;    If you want to re-write the marked chunk (in ==='s) then all you
  71. ;    need to know is that on entry to this bit, ST_Command contains the
  72. ;    address of the start of all parameters, and ST_Bytes contains the
  73. ;    number of bytes in the parameter.
  74. ;    When you recall the Infile and Outfile, place them in the two
  75. ;    buffers InFile and OutFile.
  76.         move.l    ST_Command,a0
  77.         move.l    ST_Bytes,d0
  78.         subq.l    #$01,d0
  79.         beq    ST_UsageErr
  80. ST_SearchIn:    cmp.b    #$20,(a0)+
  81.         bne    ST_FoundA
  82.         dbra    d0,ST_SearchIn
  83.         bra    ST_UsageErr        ; No Correct <input>
  84. ST_FoundA:    lea    InFile(pc),a1
  85.         move.b    -1(a0),(a1)+
  86.         moveq    #$00,d4
  87. ST_CopyFN:    move.b    (a0)+,d1
  88.         subq.l    #$01,d0
  89.         addq.l    #$01,d4
  90.         cmp.l    #22,d4
  91.         beq    ST_DoneA        ; Line overflow.
  92.         tst.l    d0
  93.         beq    ST_DoneA
  94.         cmp.b    #$20,d1
  95.         beq    ST_DoneA
  96.         move.b    d1,(a1)+
  97.         bra    ST_CopyFN        ; Do input FN.
  98. ST_DoneA:    clr.b    (a1)+
  99.         tst.l    d0
  100.         beq    ST_AssumeOut        ; Assume an output FN
  101. ;
  102. ; ---- Fetch an output FN ....
  103. ST_SearchOut:    cmp.b    #$20,(a0)+
  104.         bne    ST_FoundB
  105.         dbra    d0,ST_SearchOut
  106.         bra    ST_AssumeOut        ; No Correct <input>
  107. ST_FoundB:    lea    OutFile(pc),a1
  108.         move.b    -1(a0),(a1)+
  109.         moveq    #$00,d4
  110. ST_CopyFN2:    move.b    (a0)+,d1
  111.         subq.l    #$01,d0
  112.         addq.l    #$01,d4
  113.         cmp.l    #22,d4
  114.         beq    ST_DoneB        ; Line overflow.
  115.         tst.l    d0
  116.         beq    ST_DoneB
  117.         cmp.b    #$20,d1
  118.         beq    ST_DoneB
  119.         move.b    d1,(a1)+
  120.         bra    ST_CopyFN2        ; Do input FN.
  121. ST_DoneB:    clr.b    (a1)+
  122.         bra    ST_DoConv
  123. ;
  124. ; ---- Output assumption code ....
  125. ST_AssumeOut:    lea    InFile(pc),a0
  126.         lea    OutFile(pc),a1
  127. ST_CopyInOut:    move.b    (a0)+,(a1)+
  128.         bne    ST_CopyInOut
  129.         lea    OutTerm(pc),a0
  130.         sub.l    #$01,a1
  131. ST_CopyTermOut:    move.b    (a0)+,(a1)+
  132.         bne    ST_CopyTermOut        ; Put a _lib.i on.
  133. ;
  134. ; ====================================================================
  135. ;
  136. ; ---- Do the conversion ....
  137. ST_DoConv:    jsr    ConvertFD        ; Confert to FD.
  138.         rts
  139. ST_MustCLI:    lea    ST_CLIMsg(pc),a0
  140.         jsr    PrintMessage
  141.         rts
  142. ST_UsageErr:    lea    ST_Usage(pc),a0
  143.         jsr    PrintMessage
  144.         rts
  145. ST_CLIMsg:    dc.b    "_MUST_ be run from the CLI.",10,0
  146. ST_Usage:    dc.b    "Usage: ConvertFD <Input> [<Output>]",10,0
  147. FD_Startup:    dc.b    "ConvertFD Version "
  148.         VERSION
  149.         dc.b    " by Toby Simpson. Copyright 1991 Toby Simpson",10,0
  150.         even
  151. ;
  152. ; -----------------------------------------------------------------------
  153. ;
  154. ; FD files to _lib.i converter program routines.
  155. ; Works as follows:
  156. ;
  157. ;   ID's library, base variable from the initial comment and ##base.
  158. ;   Then works through file processing library entries, ##public and
  159. ;   ##private are effectively ignored, bar a comment on the LVO line
  160. ;   if a function is private. The current bias is worked out as the
  161. ;   program progresses, with ##bias statements altering it. All bar
  162. ;   the first * comment are passed directly to the output file with
  163. ;   ; colons instead. Program stops working on reciept of the ##end
  164. ;   directive.
  165. ;
  166. ConvertFD:    jsr    CFD_DoWork        ; Do everything now.
  167.  
  168.         
  169. CFD_Quit:    moveq    #$00,d0
  170.         rts                ; Signals OK and returns
  171. ;
  172. ; ---- Keywords understood by the parser ....
  173. FD_ValidKW:    dc.b    "*",0,"##base",0,"##bias",0
  174.         dc.b    "##public",0,"##private",0,"##end",0
  175.         dc.b    0
  176. ;
  177. ; ********************************************************************
  178. ;
  179. ;    File Parser routines from Config File reader 
  180. ;    Copyright T.Simpson 1990
  181. ;
  182. ; -----------------------------------------------------------------------
  183. ;
  184. CFD_DoWork:    lea    FD_ValidKW(pc),a1
  185.         move.l    a1,RC_Keywords
  186. ;
  187. ; ---- Open input file ....
  188.         lea    InFile(pc),a0
  189.         move.l    a0,d1
  190.         move.l    #1005,d2
  191.         DOS    Open            ; Open the file.
  192.         move.l    d0,RC_InChannel        ; Store channel
  193.         beq    RC_NoFile        ; No input file.
  194. ;
  195. ; ---- Open output file ....
  196.         lea    OutFile(pc),a0
  197.         move.l    a0,d1
  198.         move.l    #1006,d2
  199.         DOS    Open            ; Open the file.
  200.         move.l    d0,RC_OutChannel    ; Store channel
  201.         beq    RC_NoOut        ; No Output file.
  202. ;
  203. ; ---- Initialise buffers ....
  204.         clr.w    RC_ByteCount
  205.         clr.l    RC_OutStat
  206.         clr.b    RC_CommentIn        ; Any comments yet
  207.         move.l    #RC_BUFFSIZE,RC_BytesEach
  208.         clr.l    RC_Bias
  209. ;
  210. ; ---- The ConvertFD bit ....
  211. CFD_Main:    bsr    RC_FetchWord        ; Find a word.
  212.         cmp.l    #-1,d0
  213.         beq    RC_End            ; Couldn't.
  214.  
  215.         cmp.b    #"*",RC_WordBuffer
  216.         beq    CFD_Comment
  217.         cmp.b    #"#",RC_WordBuffer
  218.         beq    CFD_CheckKW
  219. ;
  220. ; ---- Got a command. Copy it out now ....
  221. CFD_Alpha:    lea    FD_LVOString(pc),a0
  222.         bsr    CopyToOut        ; Copy LVO Start out
  223.         cmp.l    #-1,d0
  224.         beq    RC_OutError
  225.         lea    RC_OutWord(pc),a1
  226.         lea    RC_WordBuffer(pc),a0
  227.         moveq    #127,d4            ; Max chars.
  228. CFD_CopyFunc:    move.b    (a0)+,d0
  229.         beq    CFD_DoneFunc
  230.         cmp.b    #"(",d0
  231.         beq    CFD_DoneFunc        ; Done function.
  232.         move.b    d0,(a1)+
  233.         dbra    d4,CFD_CopyFunc
  234. ;
  235. ; ---- Error, print ....
  236.         lea    CFD_OverFlow(pc),a0
  237.         jsr    PrintMessage
  238.         bra    RC_End            ; Close and quit.
  239. CFD_OverFlow:    dc.b    "Fatal Error: Function overflowed.",10,0
  240.         even
  241. RC_OutError:    lea    CFD_WriteErr(pc),a0
  242.         jsr    PrintMessage
  243.         bra    RC_End
  244. CFD_WriteErr:    dc.b    "Fatal Error: Output file write fail.",10,0
  245.         even
  246. ;
  247. ; ---- Now tab up and put in an equate ....
  248. CFD_DoneFunc:    clr.b    (a1)+
  249.         lea    RC_OutWord(pc),a0
  250.         bsr    CopyToOut        ; Copy out func name
  251.         cmp.l    #-1,d0
  252.         beq    RC_OutError
  253.         lea    FD_EQUString(pc),a0
  254.         bsr    CopyToOut
  255.         move.l    RC_Bias,d2        ; Bias value.
  256.         add.l    #$06,RC_Bias
  257.         lea    RC_OutWord(pc),a1    ; Put data here
  258.         jsr    OutDec32        ; Convert to dec.
  259.         lea    RC_OutWord(pc),a0
  260.         bsr    CopyToOut        ; Copy bias out.
  261.         cmp.l    #-1,d0
  262.         beq    RC_OutError
  263.         lea    RC_CRLF(pc),a0
  264.         bsr    CopyToOut        ; Linefeed.
  265.         cmp.l    #-1,d0
  266.         beq    RC_OutError
  267.         bra    CFD_Main        ; Try next one.
  268. ;
  269. ; ---- Output strings ....
  270. FD_LVOString:    dc.b    "_LVO",0        ; Function header
  271. FD_EQUString:    dc.b    $09,"equ",$09,"-",0    ; Offset header
  272. RC_CRLF:    dc.b    10,0            ; Linefeed character
  273. ;
  274. ;
  275. ;    KEYWORD HANDLERS (In file directives)
  276. ;
  277. CFD_CheckKW:    bsr    RC_CheckWord        ; ID it.
  278.         tst.l    d0
  279.         bne    CFD_Main        ; Couldn't. Ignore.
  280.         tst.l    d4
  281.         beq    CFD_Comment        ; A comment line.
  282.         cmp.b    #$01,d4
  283.         beq    CFD_FFbase        ; Base
  284.         cmp.b    #$02,d4
  285.         beq    CFD_FFbias        ; Bias change/set
  286.         cmp.b    #$03,d4
  287.         beq    CFD_FFpublic        ; Public funcs.
  288.         cmp.b    #$04,d4
  289.         beq    CFD_FFprivate        ; Private funcs.
  290.         cmp.b    #$05,d4
  291.         beq    CFD_FFend        ; End of file.
  292.         bra    CFD_Main        ; Unidentified.
  293. ;
  294. ; ---- Keyword handlers ....
  295. ;    1. comments.
  296. CFD_Comment:    bsr    RC_SkipToEOL
  297.         cmp.l    #-1,d0
  298.         beq    RC_End            ; EOF reached.
  299.         lea    VD_SkipCom(pc),a0
  300.         jsr    PrintMessage
  301.         bra    CFD_Main
  302. VD_SkipCom:    dc.b    ".",0
  303. ;
  304. ;    2. base.
  305. CFD_FFbase:    bsr    RC_SkipToEOL
  306.         cmp.l    #-1,d0
  307.         beq    RC_End            ; EOF reached.
  308.         lea    VD_SkipCom(pc),a0
  309.         jsr    PrintMessage
  310.         bra    CFD_Main
  311. ;
  312. ;     3. bias.
  313. CFD_FFbias:    bsr    RC_FetchWord
  314.         cmp.l    #-1,d0
  315.         beq    RC_End            ; EOF reached.
  316.         tst.b    RC_WordBuffer
  317.         beq    CFD_Main
  318.         lea    RC_WordBuffer(pc),a0
  319.         jsr    InDec16            ; Convert to decimal
  320.         and.l    #$ffff,d0
  321.         move.l    d0,RC_Bias        ; Set new bias.
  322.         lea    VD_Bias(pc),a0
  323.         jsr    PrintMessage
  324.         move.l    RC_Bias,d2
  325.         lea    RC_WordBuffer(pc),a0
  326.         jsr    OutDec32
  327.         lea    RC_WordBuffer(pc),a0
  328.         jsr    PrintMessage
  329.         lea    RC_CRLF(pc),a0
  330.         jsr    PrintMessage        ; Prompt on vdu
  331.         bra    CFD_Main
  332. VD_Bias:    dc.b    10,"Library offset @",0
  333. ;
  334. ;    4. private
  335. CFD_FFprivate:    st.b    RC_Private        ; Private functions.
  336.         lea    VD_Pri(pc),a0
  337.         jsr    PrintMessage
  338.         bra    CFD_Main
  339. VD_Pri:        dc.b    "[pri]",0
  340. ;
  341. ;    5. Public
  342. CFD_FFpublic:    clr.b    RC_Private        ; Public functions.
  343.         lea    VD_Pub(pc),a0
  344.         jsr    PrintMessage
  345.         bra    CFD_Main
  346. VD_Pub:        dc.b    "[pub]",0
  347. ;
  348. ;     6. End.
  349. CFD_FFend:    lea    FD_EndString(pc),a0
  350.         jsr    CopyToOut        ; Place EOF string.
  351.         lea    VD_End(pc),a0
  352.         jsr    PrintMessage
  353.         bra    RC_End            ; Quit.
  354. FD_EndString:    dc.b    10,"; End of _libfile",10,0
  355. VD_End:        dc.b    10,"End of _libfile.",10,0
  356.         even
  357. ;
  358. ;
  359. ;    SUPPORT ROUTINES FOR PARSER.
  360. ;
  361. ; ---- ID word from config list ....
  362. RC_CheckWord:    moveq    #$00,d4
  363.         move.l    RC_Keywords,a1
  364.         lea    RC_WordBuffer(pc),a0
  365. RC_IDWord:    bsr    RC_Compare        ; Compare two strings
  366.         tst.b    d0
  367.         beq    RC_CheckYes        ; ID'd keyword.
  368. RC_NextKW:    tst.b    (a1)+
  369.         bne    RC_NextKW
  370.         addq.l    #$01,d4
  371.         tst.b    (a1)            ; End of list?
  372.         beq    RC_CheckDone        ; Unidentified keyword        
  373.         bra    RC_IDWord        ; Try this one now...
  374. RC_CheckDone:    st.b    d0
  375.         rts                ; No.
  376. RC_CheckYes:    moveq    #$00,d0
  377.         rts                ; Yes.
  378. ;
  379. ; ---- Simple compare routine ....
  380. RC_Compare:    movem.l    a0-a1,-(sp)        ; Store work regs.
  381. RC_CLoop:    tst.b    (a0)
  382.         beq    RC_CEnd            ; End of compare
  383.         cmp.b    (a0)+,(a1)+
  384.         beq    RC_CLoop
  385. RC_CFail:    st.b    d0
  386. RC_CQUIT:    movem.l    (sp)+,a0-a1
  387.         rts                ; Signal fail and end
  388. RC_CEnd:    tst.b    (a1)
  389.         bne    RC_CFail
  390.         moveq    #$00,d0
  391.         bra    RC_CQUIT        ; Signal match and return
  392. ;
  393. ; ---- End and closedown processors ....
  394. RC_End:        bsr    PurgeOut        ; Purge output buffer
  395.         move.l    RC_OutChannel,d1
  396.         DOS    Close            ; Close up
  397.         move.l    RC_InChannel,d1
  398.         DOS    Close            ; Close up
  399.         moveq    #$00,d0
  400.         bra    RC_QUIT            ; Signal OK and return
  401. RC_NoOut:    move.l    RC_InChannel,d1
  402.         DOS    Close            ; Close other one
  403.         lea    RC_NoOF(pc),a0
  404.         jsr    PrintMessage
  405.         st.b    d0
  406.         rts
  407. RC_NoIF:    dc.b    "Can't open input file.",10,0
  408.         even
  409. RC_NoFile:    lea    RC_NoIF(pc),a0
  410.         jsr    PrintMessage
  411.         st.b    d0
  412. RC_QUIT:    rts                ; Signal fatal and return
  413. RC_NoOF:    dc.b    "Can't open output file.",10,0
  414.         even
  415. ;
  416. ; ---- Fetch one word from config buffer ....
  417. RC_FetchWord:    clr.b    RC_WordBuffer        ; Invalidate word
  418.         clr.b    RC_QuoteOn        ; Quotes.
  419.         bsr    RC_FetchChar
  420.         cmp.l    #-1,d0
  421.         beq    RC_EndOfFile
  422.         cmp.b    #$20,d0
  423.         bls    RC_FetchWord
  424.         cmp.b    #$7f,d0
  425.         bhs    RC_FetchWord        ; All invalid chars
  426. ;
  427. ; ---- OK! We have a valid start char ....
  428.         lea    RC_WordBuffer(pc),a5
  429.         cmp.b    #$22,d0
  430.         beq    RC_QuoteCode        ; Quote handler
  431.         move.b    d0,(a5)+        ; Store first char
  432. RC_GetAll:    bsr    RC_FetchChar        ; Fetch a byte.
  433.         cmp.l    #-1,d0
  434.         beq    RC_EndOfFile
  435.         cmp.b    #$22,d0
  436.         beq    RC_QuoteCode        ; Handle quotes.
  437.         cmp.b    #$20,d0
  438.         bne    RC_NoSpace        ; Not space
  439.         tst.b    RC_QuoteOn
  440.         beq    RC_Terminate
  441. RC_NoSpace:    cmp.b    #$20,d0
  442.         blo    RC_Terminate
  443.         cmp.b    #$7f,d0
  444.         bhs    RC_Terminate        ; EOW conditions
  445.         move.b    d0,(a5)+        ; Store character
  446.         cmp.l    #RC_EndWordBuf,a5
  447.         beq    RC_WordOverflow        ; Word overflow
  448.         bra    RC_GetAll
  449. RC_QuoteCode:    not.b    RC_QuoteOn        ; Toggle quote code.
  450.         bra    RC_GetAll        ; Back to loop.
  451. RC_Terminate:    clr.b    (a5)            ; NULL terminate word
  452.         moveq    #$00,d0
  453.         rts
  454. RC_EndOfFile:    rts 
  455. RC_WordOverflow:bsr    RC_SkipToEOL
  456.         rts
  457. ;
  458. ; ---- Skip to end of line ....
  459. RC_SkipToEOLB:    bsr.s    RC_SkipToEOL
  460.         cmp.l    #-1,d0
  461.         beq    RC_EndOfFile
  462.         bra    RC_FetchWord        ; For non JSR call
  463. RC_SkipToEOL:    bsr    RC_FetchChar
  464.         cmp.l    #-1,d0
  465.         beq    RC_EOF            ; EOF reached
  466.         cmp.b    #$0a,d0
  467.         bne    RC_SkipToEOL
  468. RC_EOF:        rts
  469. ;
  470. ; ---- Fetch one character ....
  471. RC_FetchChar:    tst.w    RC_ByteCount        ; Buffer empty?
  472.         beq    RC_FetchMore        ; Yup, get more
  473.         lea    RC_Buffer(pc),a0    ; Addr of buffer
  474.         moveq    #0,d0
  475.         move.w    RC_BytesIn,d0
  476.         sub.w    RC_ByteCount,d0
  477.         move.b    0(a0,d0.w),d0        ; Fetch buffered char.
  478. ;        tst.b    RC_QuoteOn
  479. ;        bne    RC_NoLC            ; Don't touch, quotes!
  480. ;        cmp.b    #"A",d0
  481. ;        blo    RC_NoLC
  482. ;        cmp.b    #"Z",d0
  483. ;        bhi    RC_NoLC
  484. ;        add.b    #$20,d0            ; Force LC
  485. RC_NoLC:    sub.w    #$01,RC_ByteCount
  486.         rts                ; Next char & return
  487. ;
  488. RC_FetchMore:    lea    RC_Buffer(pc),a0
  489.         move.l    a0,d2
  490.         move.l    RC_BytesEach,d3
  491.         move.l    RC_InChannel,d1
  492.         DOS    Read            ; Read some characters
  493.         cmp.l    #-1,d0
  494.         beq    RC_EndFile        ; Error.
  495.         move.w    d0,RC_BytesIn
  496.         move.w    d0,RC_ByteCount        ; Buffer fullish
  497.         tst.w    d0
  498.         beq    RC_EndFile
  499.         bra    RC_FetchChar        ; All done!        
  500. RC_EndFile:    move.l    #-1,d0
  501.         rts                ; Error & return.
  502. ;
  503. ; ---- Output buffer managers ....
  504. ;
  505. ;    1. One NULL terminated string to output.
  506. CopyToOut:    move.b    (a0)+,d0
  507.         beq    CTO_End            ; End
  508.         bsr    OutCharacter        ; Output this chr
  509.         cmp.l    #-1,d0
  510.         beq    CTO_End
  511.         bra    CopyToOut
  512. CTO_End:    rts
  513. ;
  514. ;    2. One character (d0) to output buffers.
  515. OutCharacter:    movem.l    a0/d1-d4/d7,-(sp)
  516.         cmp.w    #RC_BUFFSIZE,RC_OutStat
  517.         beq    OC_BuffFull
  518. OC_PlaceHere:    lea    RC_OutBuffer(pc),a0
  519.         move.w    RC_OutStat,d1
  520.         move.b    d0,0(a0,d1.w)        ; Store character.
  521.         add.w    #$01,RC_OutStat        ; Next Psn.
  522. OC_Quit:    movem.l    (sp)+,a0/d1-d4/d7
  523.         rts
  524. OC_BuffFull:    move.l    d0,d7
  525.         moveq    #$00,d3
  526.         move.w    RC_OutStat,d3
  527.         move.l    RC_OutChannel,d1
  528.         lea    RC_OutBuffer(pc),a0
  529.         move.l    a0,d2
  530.         DOS    Write            ; Write this block
  531.         cmp.l    #-1,d0
  532.         beq    OC_Quit            ; ERROR.
  533.         clr.w    RC_OutStat        ; Reset counter
  534.         move.l    d7,d0
  535.         bra    OC_PlaceHere
  536. ;
  537. ;     3. Purge buffer.
  538. PurgeOut:    moveq    #$00,d3
  539.         move.w    RC_OutStat,d3
  540.         move.l    RC_OutChannel,d1
  541.         lea    RC_OutBuffer(pc),a0
  542.         move.l    a0,d2
  543.         DOS    Write            ; Write this block
  544.         rts
  545. ;
  546. ; ---- Variables used in config routines ....
  547. RC_OutBuffer:    dcb.b    RC_BUFFSIZE+1,0        ; Output buffer
  548. RC_Buffer:    dcb.b    RC_BUFFSIZE+1,0        ; Small buffer
  549.         even
  550. RC_WordBuffer:    dcb.b    150,0            ; Small buffer
  551. RC_EndWordBuf:    dc.w    0            ; End word buffer
  552. RC_ByteCount:    dc.w    0            ; Bytes in buffer
  553. RC_BytesEach:    dc.l    RC_BUFFSIZE
  554. RC_QuoteOn:    dc.w    0            ; Quote toggle flag
  555. RC_Keywords:    dc.l    0            ; Address of kw table
  556. RC_Return:    dc.l    0            ; Address of return area
  557. RC_Bytes:    dc.l    0            ; Size of return area
  558. RC_InChannel:    dc.l    0            ; File handle.
  559. RC_OutChannel:    dc.l    0            ; Output channel
  560. RC_BytesIn:    dc.l    0            ; Bytes in to work with
  561. RC_OutStat:    dc.l    0            ; Bytes in o/p buffer
  562. RC_CommentIn:    dc.w    0            ; Comment counter
  563. RC_Bias:    dc.l    0            ; Current offset bia
  564. RC_OutWord:    dcb.b    256,0
  565. RC_Private:    dc.w    0            ; Priv/Pub flag
  566. ;
  567. ; ---- Decimal number handlers ....
  568. ;    (Rubbish, but works)
  569. OutDec32:    lea    OD_Dividor(pc),a0    ; Address of dividor
  570.         moveq    #$03,d4            ; Iterations
  571. OD_DecLoop:    move.l    (a0)+,d1        ; Get dividor
  572.         clr.l    d0
  573. OD_DigitLoop:    sub.l    d1,d2            ; Subtract..
  574.         bcs    OD_DecOver
  575.         addq    #$01,d0            ; Digit
  576.         bra    OD_DigitLoop
  577. OD_DecOver:    add.l    d1,d2
  578.         add.b    #$30,d0
  579.         move.b    d0,(a1)+
  580.         dbra    d4,OD_DecLoop
  581.         clr.b    (a1)+
  582.         rts
  583. OD_Dividor:    dc.l    1000,100,10,1
  584. ;
  585. ; Indec - 16 bit decimal string > number conversion routine
  586. ; (C) TWS 1989. a0 address of number, d0 is returned value.
  587. ;    Revision History:
  588. ;    01-01-91  Tidied, Null rather than CR detection, faster code.
  589. ;
  590. InDec16:    movem.l    d1-d3/a0-a1,-(sp)
  591.         move.l    a0,a1
  592.         moveq    #$00,d0            ; Length of string
  593.         moveq    #$00,d1            ; Final result
  594. ID16_FLen:    tst.b    (a0)+
  595.         bne    ID16_FLen
  596.         subq.l    #$01,a0
  597.         moveq    #$01,d2            ; Units to start with
  598. ID16_ToDec:    move.b    -(a0),d0
  599.         sub.b    #$30,d0            ; ASCII > Dec
  600.         mulu    d2,d0            ; get this mul.        
  601.         add.l    d0,d1            ; Add to result
  602.         mulu    #$0a,d2            ; ..tens, hundreds etc..
  603.         moveq    #$00,d0
  604.         cmp.l    a0,a1
  605.         bne    ID16_ToDec
  606.         move.l    d1,d0
  607.         movem.l    (sp)+,d1-d3/a0-a1
  608.         rts
  609. ;
  610. ; -----------------------------------------------------------------------
  611. ;
  612.         end
  613.